<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>3.基本使用</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../js/vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo"></div>

    <script type="text/javascript">

      // 第一步：创建组件（定义组件）
      let Person = Vue.extend({
        template:`
          <div>
            <h1>人员信息</h1>
            <h3>姓名：{{personName}}</h3>
            <h3>年龄：{{personAge}}</h3>
            <button @click="showPerson">点我提示个人信息</button>  
          </div>
        `,
        data(){
          return {
            personName:'小橙子',
            personAge:18,
          }
        },
        methods:{
          showPerson(){
            alert(`我叫${this.personName}，我今天${this.personAge}岁了`)
          }
        }
      })

      let School = Vue.extend({
        template:`
          <div>
            <h1>学校信息</h1>
            <h3>校名：{{schoolName}}</h3>
            <h3>地址：{{schoolAddress}}</h3>
            <button @click="showSchool">点我提示学校信息</button>
          </div>
        `,
        data(){
          return {
            schoolName:'尚硅谷',
            schoolAddress:'宏福科技园'
          }
        },
        methods:{
          showSchool(){
            alert(`${this.schoolName}坐落于${this.schoolAddress}`)
          }
        }
      })

      let Hello = Vue.extend({
        template:`<h1>你好</h1>`
      })

      new Vue({
        el:'#demo',
        template:`
          <div>
            <Hello></Hello>
            <hr>
            <Person></Person>
            <hr>
            <School></School>
          </div>
        `,
        // 第二步：注册组件
        components:{Person,School,Hello}
      })

    </script>
  </body>
</html>